import 'package:get/get.dart';
import 'package:mmkv/mmkv.dart';

import '../../../constants.dart';
import '../../../routes/app_routes.dart';
import '../../web_screen/screen_params.dart';

class SettingsLogic extends GetxController {
  final mmkv = MMKV.defaultMMKV();

  final agreementUrl = 'https://api.seedfour.com/res/api/v1/user/agreement';
  final privacyUrl = 'https://api.seedfour.com/res/api/v1/user/privacy';

  void onClickAgreement() {
    Get.toNamed(RouteGet.webScreen,
        arguments: WebScreenParams(url: agreementUrl));
  }

  void onClickPrivacy() {
    Get.toNamed(RouteGet.webScreen,
        arguments: WebScreenParams(url: privacyUrl));
  }

  void onClickChangePassword() {
    Get.toNamed(RouteGet.changePassword);
  }

  void onClickSetPayPassword() {
    Get.toNamed(RouteGet.setPayPassword);
  }

  void onClickLogout() {
    _logout();
    Get.offAllNamed(RouteGet.login);
  }

  void _logout() {
    mmkv.encodeString(kKeyToken, '');
    mmkv.encodeString(kKeyOrgId, '');
  }
}
